/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.Brews;
import com.openbrew.openbrewrf.TastePanelBeer;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Beer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BeerVew.findAllASC", query = "SELECT b FROM BeerView b ORDER BY b.bName ASC"),
    @NamedQuery(name = "BeerVew.findAllDSC", query = "SELECT b FROM BeerView b ORDER BY b.bName DESC"),
    @NamedQuery(name = "BeerView.findProductionASC", query = "SELECT b FROM BeerView b WHERE b.inProduction='true' ORDER BY b.bName ASC")})
public class BeerView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "BId")
    private Integer bId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 40)
    @Column(name = "BName")
    private String bName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "InProduction")
    private boolean inProduction;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BAbv")
    private float bAbv;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BIbu")
    private float bIbu;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BSrm")
    private float bSrm;
    @Basic(optional = false)
    @NotNull
    @Column(name = "RecipeID")
    private int recipeID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BCOVols")
    private float bCOVols;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bBeerID")
    private Collection<Brews> brewsCollection;
    @OneToMany(mappedBy = "tPBBeer")
    private Collection<TastePanelBeer> tastePanelBeerCollection;
    @OneToMany(mappedBy = "bBeerID")
    private Collection<FGIView> fgiViewsCollection;

    public BeerView() {
    }

    public BeerView(Integer bId) {
        this.bId = bId;
    }

    public BeerView(Integer bId, String bName, boolean inProduction, float bAbv, float bIbu, float bSrm, int recipeID, float bCOVols) {
        this.bId = bId;
        this.bName = bName;
        this.inProduction = inProduction;
        this.bAbv = bAbv;
        this.bIbu = bIbu;
        this.bSrm = bSrm;
        this.recipeID = recipeID;
        this.bCOVols = bCOVols;
    }

    public Integer getbId() {
        return bId;
    }

    public void setbId(Integer bId) {
        this.bId = bId;
    }

    public String getbName() {
        return bName;
    }

    public void setbName(String bName) {
        this.bName = bName;
    }

    public boolean isInProduction() {
        return inProduction;
    }

    public void setInProduction(boolean inProduction) {
        this.inProduction = inProduction;
    }

    public float getbAbv() {
        return bAbv;
    }

    public void setbAbv(float bAbv) {
        this.bAbv = bAbv;
    }

    public float getbIbu() {
        return bIbu;
    }

    public void setbIbu(float bIbu) {
        this.bIbu = bIbu;
    }

    public float getbSrm() {
        return bSrm;
    }

    public void setbSrm(float bSrm) {
        this.bSrm = bSrm;
    }

    public int getRecipeID() {
        return recipeID;
    }

    public void setRecipeID(int recipeID) {
        this.recipeID = recipeID;
    }

    public float getBCOVols() {
        return bCOVols;
    }

    public void setBCOVols(float bCOVols) {
        this.bCOVols = bCOVols;
    }

    @XmlTransient
    public Collection<Brews> getBrewsCollection() {
        return brewsCollection;
    }

    public void setBrewsCollection(Collection<Brews> brewsCollection) {
        this.brewsCollection = brewsCollection;
    }

    @XmlTransient
    public Collection<TastePanelBeer> getTastePanelBeerCollection() {
        return tastePanelBeerCollection;
    }

    public void setTastePanelBeerCollection(Collection<TastePanelBeer> tastePanelBeerCollection) {
        this.tastePanelBeerCollection = tastePanelBeerCollection;
    }

    @XmlTransient
    public Collection<FGIView> getFGIViewsCollection() {
        return fgiViewsCollection;
    }

    public void setFGIViewsCollection(Collection<FGIView> fgiViewsCollection) {
        this.fgiViewsCollection = fgiViewsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bId != null ? bId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof POSBeerView)) {
            return false;
        }
        BeerView other = (BeerView) object;
        if ((this.bId == null && other.bId != null) || (this.bId != null && !this.bId.equals(other.bId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.BeerView[ bId=" + bId + " ]";
    }
}
